﻿var status = 0;
var objDate=new Date();
var day=objDate.getDay();
var Month= objDate.getMonth();
var MonthS =["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","十二月"];
var weekday = ["日", "一", "二", "三", "四", "五", "六"];
var MonthB=objDate.getMonth()-1;
var tzc =objDate.getDate();
var Year =objDate.getFullYear();

var itemList = Array(
Array(2434503,1),//從下一個開始
Array(2435932,1),                   //1
Array(2432306,1),            //2
Array(1073169,1),               //3
Array(2435932,1),//4
Array(2432306,1),//5
Array(2432228,1),//6
Array(1049003,1),//7
Array(2435932,1),//8
Array(2432306,1),//9
Array(1082703,1),//10
Array(2435932,1),//11
Array(2432306,1),//12
Array(2432228,1),//13
Array(1062182,1),//14
Array(2435932,1),//15
Array(2432306,1),//16
Array(1004844,1), //17
Array(2435932,1),//18
Array(2432306,1),//19
Array(2432228,1),//20
Array(1073109,1),//21
Array(2435932,1),//22
Array(2432306,1),//23
Array(1053095,1),//24
Array(2435932,1),//25
Array(2432306,1),//26
Array(2432228,1),//27
Array(1082503,1),//28
Array(2435932,1),//29
Array(2432306,1),//30
Array(1702714,1)
);//31 因為沒0日 從第1開始設置物品 第一格道具id 第二格設置數量

var debug = false;

function start() {
    status = -1;
	if(debug && cm.getPlayer().getGMLevel() < 4){
		cm.dispose();
		return;
	}
    action(1, 0, 0);
}

function action(mode, type, selection) {
    if (mode == -1) {
        cm.dispose();
    } else {
        if (mode == 0 && status == 0) {
            cm.dispose();
            return;
        }
        if (mode == 1) status++;
        else status--;
        if (status == 0) {


var tt=31;
if (Month == 0 || Month == 2 || Month == 4 || Month == 6|| Month == 7 || Month == 9 || Month == 11 ) { // 1月 3月 5月 78 月 10月 12月
tt=32;
}
if (Month == 1) { // 2月的話
tt=29;
}
              var text3 = 0;
for(var i=1; i<tt; i++) {
text3+= cm.getPrizeLog(""+Year+"年"+MonthS[Month]+i+"日");}
             
              var ta="#b";

              var text = "";

		for(var i=1,ytz=1; i<tt; i++,ytz++) {
if (cm.getPrizeLog(""+Year+"年"+MonthS[Month]+i+"日") == 0) {
ta="#b";
}
if (cm.getPrizeLog(""+Year+"年"+MonthS[Month]+i+"日") != 0) {
ta="#r";
}
			text+=ta+ytz+"#i"+itemList[i][0]+"#"+((i + 0) % 7 == 0 ? "\r\n": "");
		}
            var text2 = 0;

 cm.sendSimple("#e現在時間:#b"+Year+"年"+MonthS[Month]+tzc+"日星期"+weekday[day]+"\r\n#k這個月共簽到【#r"+text3+"#k】次\r\n須今日在線時數#r120#k分鐘\r\n\您今日在線時數為:#e#r"+cm.getOnlineTime()+"#k分鐘\r\n#k#e今日獎勵為#b#i"+itemList[tzc][0]+"##r#z"+itemList[tzc]+"##k【#r"+itemList[tzc][1]+"#k】個#b\r\n#L0#領取今日獎勵#L1#領取連續簽到獎勵#l\r\n\r\n#k以下為【#b"+Year+"年"+MonthS[Month]+"份#k】獎勵\r\n(#b藍色=#k未簽到,#r紅色=#k以簽到)\r\n\r\n"+text);
} else if (status == 1) {


            if (selection == 0) {
 if(!cm.canHold(itemList[tzc][0], itemList[tzc][1])){
             cm.sendOk("您的背包空間不足");
             cm.dispose();
             return;   
             }
  if (cm.getPrizeLog(""+Year+"年"+MonthS[Month]+tzc+"日") < 1 && cm.getOnlineTime()>= 120) { // 在線時數120
                    cm.setPrizeLogg(""+Year+"年"+MonthS[Month]+tzc+"日");
           
                    cm.gainItem(itemList[tzc][0], itemList[tzc][1]);

                    cm.sendOk("以領取每日簽到獎勵。");
     cm.worldSpouseMessage(0x0C, "『每日簽到』" + " : " + "玩家 " + cm.getChar().getName() + " 已经領取簽到獎利！");
                    cm.dispose();
                        
                } else{ // 不是隊長
                    cm.sendOk("以領取過或在線時間不到120分鐘。");
                    cm.dispose();
                 } 


        } else if (selection == 1) {

if(MonthB < 0)
MonthB=11;
cm.sendSimple("#r========================================\r\n#b#L0#"+MonthS[MonthB]+"簽到獎勵\r\n\r\n#L1#"+MonthS[Month]+"簽到獎勵#l\r\n\r\n#r========================================");
                    

}
}else if (status == 2) {
 cm.dispose();
   if (selection == 0) {
              cm.openNpc(2008,998);
            } else if (selection == 1) {
            cm.openNpc(2008,1000);
         } 
}

}

}